<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加图书</title>
    <script src="../../../static/js/vue.js"></script>
    <script src="../../../static/js/config.js"></script>
    <link rel="stylesheet" href="../../../static/layui/css/layui.css"></link>
    <script src="../../../static/js/jquery-3.3.1.min.js"></script>
</head>
<body>
<div id="app">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>增加一个图书</legend>
    </fieldset>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">书名:</label>
            <div class="layui-input-block">
                <input type="text" v-model="name" name="title" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">作者:</label>
            <div class="layui-input-block">
                <input type="text" v-model="author" name="title" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">价格:</label>
            <div class="layui-input-block">
                <input type="text" v-model="price" name="title" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" @click="submit">submit</button>
            </div>
        </div>
    </form>
</div>
<script src="../../../static/layui/layui.js"></script>
<script src="../../../static/js/store.js"></script>
<script>
    layui.use('form', function(){

    });
</script>
<script type="text/javascript">
    var vm = new Vue({
        el: '#app',
        data: {
            name:'',
            author:'',
            price:''
        },
        methods: {
            submit:function () {
                apiConfig.addBookApi({name:this.name,author:this.author,price:this.price}).then(function (result) {
                    // if (methodConfig.requestMethod(result)){
                    //     window.location.href = webConfig.booksHtml
                    // }
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                })
            }
        }
    })
</script>
</body>
</html>